﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using OnlineVideos.UI;
using Common.Library;
using Common.Utilities;
using OnlineVideos.Entities;
using InsertIntoDataBase;

namespace OnlineMovies.Views
{
    public class val
    {
        public int PersonID
        {
            get;
            set;
        }
        public string Name
        {
            get;
            set;
        }
        public string FlickrPersonImageUrl
        {
            get;
            set;
        }
        public string Description
        {
            get;
            set;
        }
    }
    public partial class AddMatchBowling : PhoneApplicationPage
    {
        public List<val> CastList = new List<val>();
        public AddMatchBowling()
        {
            InitializeComponent();
            Loaded += AddMatchBowling_Loaded;
        }

        void AddMatchBowling_Loaded(object sender, RoutedEventArgs e)
        {
            if (ResourceHelper.AppName != Apps.Indian_Cinema_Pro.ToString() && ResourceHelper.AppName != Apps.Kids_TV_Pro.ToString() && ResourceHelper.AppName != Apps.Story_Time_Pro.ToString())
                LoadAds();
        }
        private void LoadAds()
        {
            try
            {
                PageHelper.LoadAdControl(LayoutRoot, adstackpl, 4);
            }
            catch (Exception ex)
            {
                Exceptions.SaveOrSendExceptions("Exception in LoadAds Method In SongDetails file", ex);
                string excepmess = "Exception in LoadAds Method In SongDetails file.\n\n" + ex.Message + "\n\n StackTrace :- \n" + ex.StackTrace;
            }

        }
        private void imgTitle_MouseEnter(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            NavigationService.Navigate(NavigationHelper.MainPanoramaPage);
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.NavigationMode != NavigationMode.Back)
            {

                CastList = Constants.connection.Table<CastProfile>().ToListAsync().Result.Select(i => new val { PersonID = i.PersonID, Name = i.Name, FlickrPersonImageUrl = i.FlickrPersonImageUrl, Description = i.Description }).ToList();
                tblkpersonname.ItemsSource = CastList;
            }
        }
        private void lpictype_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {

        }

        private void tblkpersonname_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {

        }

        private void btnsave_Click_1(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(tblkpersonname.Text))
            {

                validname.Visibility = Visibility.Collapsed;
                InsertData<MatchBowlingScore> insert = new InsertData<MatchBowlingScore>();
                insert.ParameterList = new MatchBowlingScore();
                insert.ParameterList.MatchId = AppSettings.ShowUniqueID;
                insert.ParameterList.Maidens =Convert.ToInt32(txtmaidens.Text);
                insert.ParameterList.Overs = Convert.ToDouble(txtovers.Text);
                insert.ParameterList.Runs =Convert.ToInt32(txtruns.Text);
                insert.ParameterList.PlayerName = tblkpersonname.Text;
                insert.ParameterList.Wickets =Convert.ToInt32(txtwickets.Text);
                insert.ParameterList.TeamType =lpictype.SelectedItem.ToString();
               //insert.ParameterList.PlayerID=
                      insert.Insert();
            }
            else
            {
                validname.Visibility = Visibility.Visible;
            }
        }

        private void TextBlock_Loaded_1(object sender, RoutedEventArgs e)
        {

        }
    }
}